package com.ljh.oj.model.enums;

import java.util.List;
import java.util.stream.Stream;

/**
 * 提交得语言类型 Java C++ Python,Go
 */
public enum QuestionSubmitLanguageEnum {
    JAVA("java", "java"),
    CPLUSPLUS("c++", "c++"),
    PYTHON("python", "python"),
    GOLANG("golang", "golang");

    public String getText() {
        return text;
    }

    private final String text;

    public String getValue() {
        return value;
    }

    private final String value;

    QuestionSubmitLanguageEnum(String text, String value) {
        this.text = text;
        this.value = value;
    }

    /**
     * 获取枚举值列表
     * @return
     */
    public static List<String> getValues() {
        return Stream.of(QuestionSubmitLanguageEnum.values())
                .map(QuestionSubmitLanguageEnum::getValue).toList();
    }
    public static QuestionSubmitLanguageEnum getEnum(String value) {
        if(value==null){
            return null;
        }
        return Stream.of(QuestionSubmitLanguageEnum.values())
                .filter(e -> e.getValue().equals(value))
                .findFirst().orElse(null);
    }
}
